package my.jbf.firstGame.BITMAP;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
import android.view.MotionEvent;

import my.jbf.firstGame.GAMEDATA.SharedPreferenceManager;
import my.jbf.firstGame.MODULE.MyParsePath;
import my.jbf.firstGame.MainActivity;

public class Enemy {
    private final Canvas mCanvas;
    private final SharedPreferenceManager mSPM;
    private final Paint mPaint;
    private final Bitmap mBitmap;
    
    
    private PointF LeftTopPoint;//屏幕坐标
    private PointF RightBottomPoint;
    private PointF CenterPoint;//地图坐标
	private PointF mMoved;
    private final Path mPath;
	private final float mali;
	private final float heavy;
	private final float speed;
	private final float a;
	private final float fLAND;
    private final float fWIND;
	
	private final float aX;
    private final float aY;
    private final float vX;
    private final float vY;
	



    public Enemy(Point mapPoint) {
        mPath=new Path();
        String path="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z";
        mPath.addPath( new MyParsePath().parsePath(path));
        mSPM = MainActivity.mSPM;
        
        CenterPoint=new PointF(mapPoint);
        LeftTopPoint=new PointF();
        RightBottomPoint=new PointF();
		mMoved=new PointF(0f,0f);
        mPaint = new Paint();
        mPaint.setColor(mSPM.getDirectionButtonColor());
        mPaint.setStyle(Paint.Style.STROKE);
		mPaint.setTextSize(20);
        mBitmap = Bitmap.createBitmap(100,150, Bitmap.Config.ARGB_8888);
        mCanvas = new Canvas(mBitmap);
        resetPoint();
		
		
		
		mali=200f;
		heavy=50f;
		
		speed=0f;
		vX=0f;
		vY=0f;
		aX=0f;
		aY=0f;
		a=0f;
		fLAND=0.1f;
		fWIND=0.05f;
        //reDraw();
    }

	public void setLeftTopPoint(PointF leftTopPoint)
	{
		LeftTopPoint = leftTopPoint;
	}

	public PointF getLeftTopPoint()
	{
		return LeftTopPoint;
	}

	public void setRightBottomPoint(PointF rightBottomPoint)
	{
		RightBottomPoint = rightBottomPoint;
	}

	public PointF getRightBottomPoint()
	{
		return RightBottomPoint;
	}

	public void setCenterPoint(PointF centerPoint)
	{
		CenterPoint = centerPoint;
	}

	public PointF getCenterPoint()
	{
		return CenterPoint;
	}

   

    public Bitmap getbitmap() {
		resetPoint();
        reDraw();
        return mBitmap;
    }

    private void reDraw() {
		mCanvas.drawColor(Color.GREEN);
		Path mmPath=new Path();
        String ppath="M50,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z";
        mmPath.addPath( new MyParsePath().parsePath(ppath));
		
		
		
        //mBitmap.eraseColor(Color.argb(0, 0, 0, 0));
		
		mCanvas.save();
		mCanvas.scale(16f,16f);
        mCanvas.drawPath(mPath,mPaint);
		mCanvas.restore();
		mCanvas.drawText("PLAYER",100,100,mPaint);
        
    }

    public void setMove(PointF moved)
	{
		this.mMoved=moved;
	}


    

    

   
    private void resetPoint(){
		PointF temp=new PointF(CenterPoint.x,CenterPoint.y);
		
		CenterPoint.set(CenterPoint.x+mMoved.x,CenterPoint.y+mMoved.y);
		LeftTopPoint.set(CenterPoint.x-50,CenterPoint.y-50);
		RightBottomPoint.set(CenterPoint.x+50,CenterPoint.y+100);
		

    }
	private void getSpeed()
	{
		
	}
}
